<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport"
        content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <link rel="stylesheet" type="text/css" href="../css/aui.2.0.css" />
</head>

<body>
    <header class="aui-bar aui-bar-nav" style="background-color: #03a9f4;position:fixed;" id="header">
        <a class="aui-pull-left aui-btn" tapmode onclick="closeWin();">
            <span class="aui-iconfont aui-icon-left"></span>
        </a>
        <div class="aui-title" id="title">
            看板查询
        </div>
    </header>
    <div class="aui-content aui-margin-b-15" style="margin-top:50px;">
        <ul class="aui-list aui-form-list">
            <li class="aui-list-item">
                <div class="aui-list-item-inner">
                    <div class="aui-list-item-label">要货日期起</div>
                    <div class="aui-list-item-input">
                        <input type="text" placeholder="选择日期" class="aui-input" id="needDateStart" disabled="true">
                    </div>
                </div>
            </li>
            <li class="aui-list-item">
                <div class="aui-list-item-inner">
                    <div class="aui-list-item-label">要货日期止</div>
                    <div class="aui-list-item-input">
                        <input type="text" placeholder="选择日期" class="aui-input" id="needDateEnd" disabled="true">
                    </div>
                </div>
            </li>
            <li class="aui-list-item">
                <div class="aui-list-item-inner">
                    <div class="aui-list-item-label">看板状态</div>
                    <select id="kanbanStatus" disabled="true">
                    </select>
                </div>
            </li>
            <!-- <li class="aui-list-item">
                <div class="aui-list-item-inner">
                    <div class="aui-list-item-label">数量状态</div>
                    <select id="numStatus">
                    </select>
                </div>
            </li>
            <li class="aui-list-item">
                <div class="aui-list-item-inner">
                    <div class="aui-list-item-label">看板类型</div>
                    <select id="kanbanType">
                    </select>
                </div>
            </li> -->
        </ul>
        <div style="width:100%;margin-top:2%;"></div>
        <div class="aui-btn aui-btn-info aui-btn-block" onclick="searchData()">查询</div>
        <div
            style="background-color:white; width: 100%;margin-top:2%;white-space: nowrap;overflow-x: auto;overflow-y: auto;-webkit-overflow-scrolling:touch;">
            <table class="table" style='width:1780px;' id="table1">
                <tbody style="display:block">
                    <tr
                        style="text-align: center;background-color: #DCE9F2;color: #467aa7;font-size: 15px;font-weight: bold;">
                        <td algin='center' style="width:50px">序号</td>
                        <td algin='center' style="width:160px">看板号</td>
                        <td algin='center' style="width:200px">工单号</td>
                        <td algin='center' style="width:120px">要货日期</td>
                        <td algin='center' style="width:300px">供应商名称</td>
                        <td algin='center' style="width:170px">物料号</td>
                        <td algin='center' style="width:300px">物料名</td>
                        <td algin='center' style="width:120px">要货数量</td>
                        <td algin='center' style="width:120px">看板状态</td>
                        <td algin='center' style="width:120px">数量状态</td>
                        <td algin='center' style="width:120px">看板类型</td>
                    </tr>
                </tbody>
            </table>
            <table class="table" style='width:1780px;' id="table">
                <tbody id="tbodyHtml" style="display: block;height: 510px;overflow-y: scroll;">
                </tbody>
            </table>
        </div>
    </div>
</body>
<script type="text/javascript" src="../script/api.js"></script>
<script type="text/javascript" src="../script/jquery-1.8.2.min.js"></script>
<script type="text/javascript" src="../script/public.js"></script>
<script type="text/javascript" src="../script/echarts.min.js"></script>
<script type="text/javascript">
    //初始化
    apiready = function () {

        //看板状态
        var kanbanStatus = api.pageParam.kanbanStatus;
        //要货日期起
        var needDateStart = api.pageParam.needDateStart;
        //要货日期止
        var needDateEnd = api.pageParam.needDateEnd;

        //初始化当前日期
        // crateDate();
        $("#needDateStart").val(needDateStart);
        $("#needDateEnd").val(needDateEnd);

        //查询看板状态下拉框
        getCombox("kanbanStatus", kanbanStatus);
        // //查询数量状态下拉框
        // getCombox("numStatus", "");
        // //查询看板类型下拉框
        // getCombox("kanbanType", "");
    }

    //获取当前日期
    function crateDate() {
        var date = new Date();
        var year = date.getFullYear();
        var month = date.getMonth() + 1 < 10 ? "0" + (date.getMonth() + 1) : date.getMonth() + 1;
        var day = date.getDate() < 10 ? "0" + date.getDate() : date.getDate();
        $("#needDate").val(year + "-" + month + "-" + day);
    }

    //查询下拉框(看板状态，看板类型，数量状态)
    function getCombox(id, value) {

        var un = localStorage.getItem('un');
        var serverUrl = localStorage.getItem('serverUrl');
        var url = serverUrl + "/app/getMdparaconfig";
        var data = {
            values: {
                paracls: id
            }
        };
        api.ajax({
            url: url,
            method: 'post',
            dataType: 'json',
            timeout: 300,
            returnAll: false,
            data: data
        }, function (ret, err) {
            if (ret) {
                var data = JSON.stringify(ret);
                var myobj = eval("(" + data + ")");

                //成功
                if (myobj.code == "0") {

                    var list = eval(myobj.list);
                    var html = "<option value=''>--请选择--</option>";
                    for (var i = 0; i < list.length; i++) {
                        html += "<option value='" + list[i].code + "'>" + list[i].name + "</option>";
                    }
                    $api.html($api.byId(id), html);

                    $("#" + id).val(value);

                    //查询数据
                    searchData();
                } else {
                    api.toast({
                        msg: myobj.message,
                        duration: 3000
                    });
                }
            } else {
                alert(JSON.stringify(err));
            }
        });
    }

    //时间选择器
    function timePicker(id) {
        api.openPicker({
            type: 'date',
            date: new Date(),
            title: '选择日期'
        }, function (ret, err) {
            if (ret) {
                var monthTemp = (ret.month < 10 ? '0' + ret.month : ret.month);
                var dayTemp = (ret.day < 10 ? '0' + ret.day : ret.day);
                var date = ret.year + "-" + monthTemp + "-" + dayTemp;
                $("#" + id).val(date);
            }
        });
    }

    //查询表格数据
    function searchData() {
        //要货日期起
        var needDateStart = $("#needDateStart").val();
        //要货日期止
        var needDateEnd = $("#needDateEnd").val();
        //看板状态
        var kanbanStatus = $("#kanbanStatus").val();
        // //数量状态
        // var numStatus = $("#numStatus").val();
        // //看板类型
        // var kanbanType = $("#kanbanType").val();

        var un = localStorage.getItem('un');
        var serverUrl = localStorage.getItem('serverUrl');
        var url = serverUrl + "/app/getKanbanData";
        var data = {
            values: {
                needDateStart: needDateStart,
                needDateEnd: needDateEnd,
                kanbanStatus: kanbanStatus,
                // numStatus: numStatus,
                // kanbanType: kanbanType,
                un: un
            }
        };

        api.showProgress({
            title: '查询中...',
        });

        api.ajax({
            url: url,
            method: 'post',
            dataType: 'json',
            timeout: 300,
            returnAll: false,
            data: data
        }, function (ret, err) {
            if (ret) {
                var data = JSON.stringify(ret);
                var myobj = eval("(" + data + ")");

                //返回成功
                if (myobj.code == "0") {
                    var list = eval(myobj.list);
                    var html = "";
                    //遍历
                    for (var i = 0; i < list.length; i++) {
                        html += "<tr style='text-align: center;background-color: #F5F5F5;color: black;font-size: 15px;'>";
                        html += "<td name='seqno' style='width:50px;'>" + list[i].seqno + "</td>";
                        html += "<td name='kankan' style='width:160px;'>" + list[i].kankan + "</td>";
                        html += "<td name='workOrderCode' style='width:200px;'>" + list[i].workOrderCode + "</td>";
                        html += "<td name='needDate' style='width:120px;'>" + list[i].needDate + "</td>";
                        html += "<td name='supplierName' style='width:300px;'>" + list[i].supplierName + "</td>";
                        html += "<td name='sitmCode' style='width:170px;'>" + list[i].sitmCode + "</td>";
                        html += "<td name='sitmName' style='width:300px;'>" + list[i].sitmName + "</td>";
                        html += "<td name='needQty' style='width:120px;'>" + list[i].needQty + "</td>";
                        html += "<td name='kanbanStatus' style='width:120px;'>" + list[i].kanbanStatus + "</td>";
                        html += "<td name='numStatus' style='width:120px;'>" + list[i].numStatus + "</td>";
                        html += "<td name='kanbanType' style='width:120px;'>" + list[i].kanbanType + "</td>";
                        html += "</tr>";
                    }

                    $api.html($api.byId("tbodyHtml"), html);

                } else {
                    api.toast({
                        msg: myobj.message,
                        duration: 3000
                    });
                }
                api.hideProgress();
            } else {
                api.hideProgress();
                alert(JSON.stringify(err));
            }
        });
    }
    //返回按钮
    function closeWin() {
        api.closeWin({});
    }
</script>

</html>